<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<title>服务通知转派TL</title>
		<!-- css代码 start -->
		<link href="../../../css/mui.min.css" rel="stylesheet" />
		<link href="../../../css/global.css" rel="stylesheet" />
		<link href="../../../css/style.css" rel="stylesheet" />
		<link href="../../../css/checkbox.css" rel="stylesheet" />
		<style>
			 .mui-radio input[type=radio]{
				left: 0;
				top: 11px;
			}
			.mui-checkbox label, .mui-radio label{
				padding-left: 38px;
				font-size: 14px;
				color: #333333;
				padding-right: 0;
			}
			.page_cen {
				margin-bottom: 50px;
			}
			.mui-content {
				position: relative;
			}
			.btn_box {
				width: 100%;
				margin: 0;
				padding: 0 15px;
				position: fixed;
				bottom: 0;
			}
			.pb-10{
				padding-bottom: 10px;
			}
		</style>
		<!-- css代码 end -->
	</head>
	<body>
		<!-- html代码 start -->
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 id="title" class="mui-title">服务通知转派TL</h1>
		</header>
		<div class="mui-content"> 
			
			<div class="page_cen shadow zp_cen">
				<div class="zp_sear autoHeight">
					<button class="btn" id="chaxun" onclick="getTeamleaderList()"></button>
					<div class="iptBox">
						<input type="text" id="tname" placeholder="请输入工程师名称" />
					</div>
				</div>
				<div class="jy_clum" id="qtTl">
					<!-- <div class="mui-input-row mui-radio">
						<input name="checkbox1" value="张三" type="radio" class="rds"/> 
						<label>张三</label> 
					</div>
					<div class="mui-input-row mui-radio">
						<input name="checkbox1" value="李四" type="radio" class="rds"/> 
						<label>李四</label> 
					</div>
					<div class="mui-input-row mui-radio">
						<input name="checkbox1" value="李四" type="radio" class="rds"/> 
						<label>李四</label> 
					</div> -->
				</div>
			</div>
			<div id="iphone_bottom"></div>
			<div class="btn_box">
				<span class="fl red one" id="zhuanpai">确认转派</span>
			</div>
		</div>
		<!-- html代码 end -->

		<!-- js代码 start -->

		<!-- 基础js start -->
		<script src="../../../js/mui.min.js"></script>
		<script src="../../../js/utils/h.js"></script>
		<script src="../../../js/constant.js"></script>
		<script src="../../../js/common.js"></script>
		<script src="../../../js/utils/base64.js"></script>
		<script src="../../../js/utils/md5.js"></script>
		<script src="../../../js/utils/sortMap.js"></script>
		<script src="../../../js/utils/http.js"></script>
		<script src="../../../js/app.js"></script>
		<!-- 基础js end -->

		<script type="text/javascript" charset="utf-8">

			(function($, doc) {
				$.init();
				
				var ServiceNoticeId
				var serviceNo

				$.plusReady(function() {
					
					// 从上一个页面取值
					var self = plus.webview.currentWebview();
					 // 获取上一个页面传过来的参数并显示到页面
					 ServiceNoticeId = self.ServiceNoticeId;
					 serviceNo = self.serviceNo;
					
					// 查询其它TL列表信息
					getTeamleaderList();
					
					// 兼容iphone 底部按钮挡住list问题
					if(plus.device.model.indexOf('iPhone') !== -1){
						h('#iphone_bottom').addClass('pb-10')
					}
					// 转派方法
					h("#zhuanpai").tap(function(){
						app.showWaiting('正在提交...')
						var NewTeamleaderId;
						var ele = document.getElementsByName("checkbox1");
						for (var i = 0; i < ele.length; i++) {	
							if(ele[i].checked){
								NewTeamleaderId = ele[i].value
								break
							}
						}

						ajaxGet(BASE_URL + "cc/notice/TransferTL", {
							"TeamleaderId": app.getUser().enginnerId,
							"serviceNo": serviceNo,
							"NewTeamleaderId": NewTeamleaderId
						}, function(data) {
							app.closeWaiting()
							if (data.code == 200) {
								app.toast("转派成功")
								//延迟触发，避免无法正确触发
								setTimeout(function () {
									// 查找上级页面并关闭页面
									var details = plus.webview.getWebviewById('view/service/assign/details.html');
									if (details) {
										details.close()
									}
									var assignList = plus.webview.getWebviewById('view/service/assign/assignList.html');
									if (assignList) {
										assignList.close()
									}

									// 查找需要跳转的页面，并指定刷新的方法
									var toBeAssignedList = plus.webview.getWebviewById('view/service/notice/toBeAssignedList.html');
									if(toBeAssignedList){
										self.close()
										toBeAssignedList.evalJS('initData()')
										$.back()
									}else{
										var toBeAssignedList1 = plus.webview.create('/view/service/notice/toBeAssignedList.html','view/service/notice/toBeAssignedList.html')
										toBeAssignedList1.evalJS('initData()')
										toBeAssignedList1.show()
										self.close()
									}
								},100)
							}else if(data.code == 202) {
								app.toast("CC端转派失败")
							}else{
								app.toast("转派失败")
							}
						}, function(errorMsg) {
							app.toast("转派失败")
						});
					});

				});
				
			}(mui, document));
			
			// 查询其它TL列表信息
			function getTeamleaderList(){
				app.showWaiting('加载中...')
				var tname = "";
				if(h("#tname").val()!=""){
					tname = h("#tname").val();
				}
				
				ajaxGet(BASE_URL + "cc/notice/getTeamleaderList", {
					"TeamleaderId": app.getUser().enginnerId,
					"TeamleaderName": tname
				}, function(data) {
					app.closeWaiting();
					if (data.code == 200) {
						h("#qtTl").html("");
						var html = "";
						if(data.data && data.data.length > 0){	
							for(var i=0;i<data.data.length;i++){
								var das = data.data[i];
								var teamleader_id = das.teamleader_id==undefined?"无":das.teamleader_id;
								var NAME = das.NAME==undefined?"无":das.NAME;
								var WorkDay = das.WorkDay==undefined?"无":das.WorkDay;
								var sapcode = das.sapcode==undefined?"无":das.sapcode;
								html += '<div class="mui-input-row mui-radio">'
								html += '<input name="checkbox1" value="'+teamleader_id+'" type="radio" class="rds"/> '
								html += '<label>'+NAME+'</label> '
								html += '</div>';
							}
							h("#qtTl").html(html);
						}else{
							var html = '<div class="nodata">—— 暂无数据 ——</div>';
							h("#qtTl").html(html);
						}
					} else {
						var html = '<div class="nodata">—— 暂无数据 ——</div>';
						h("#qtTl").html(html);
						app.toast(data.msg);
					}
				}, function(errorMsg) {
					app.closeWaiting();
					var html = '<div class="nodata">—— 暂无数据 ——</div>';
					h("#qtTl").html(html);
					app.toast("数据获取失败，请检查网络连接");	
				});
			}
			
		</script>
		<!-- js代码 end -->
	</body>
</html>
